<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Route
 *
 * @author Marek S
 */
class Route{
    private $controller;
    private $method;
    private $parameters;
    
    public function __construct($controller, $method, $parameters) {
        $this->controller = $controller;
        $this->method = $method;
        $this->parameters = $parameters;
    }
    
    public function execute(){
        if(class_exists($this->controller)){
            $controller = new $this->controller;
            if(method_exists($controller, $this->method)){
                $controller->executeAction($this->method);
            }
            else{
                throw new Exception('Cannot find ' . $this->method . ' in ' . $this->controller);
            }
        }
        else{
            throw new Exception('Cannot find controller ' . $this->controller);
        }
    }       
}